Skip to main content

rtos load压缩rtos

一 概述

​ 当rtos编译出来的镜像大小觉得过于庞大, 可以通过压缩将rtos镜像变小, 需要另外编译一个rtos镜像用于load解压这个被压缩的rtos镜像.

二 load压缩rtos的rtos制作

2.1 软件配置

以ad100_nor_defconfig为例

1

这个rtos只是为了load解压压缩的rtos, 固件加载地址放在ddr后面,解压压缩的rtos后,内存就可以给解压后的rtos使用

2

勾选lzma相关

3

修改完成配置后保存.

2.2 软件修改

在/rtos工程目录/freertos/vendor/vendor.c内, 修改代码如下:

#include <stdio.h>
#include "../example/driver/load_rtos_split_example.c"
void vendor_init(void *arg)
{
printf("vendor init...\n");
load_rtos_split();
}

编译rtos系统:

bhu@bhu-PC:~/rtos/freertos$ source build/envsetup.sh
bhu@bhu-PC:~/rtos/freertos$ make ad100_nor_defconfig
bhu@bhu-PC:~/rtos/freertos$ make
bhu@bhu-PC:~/rtos/freertos$ ls -l rtos-with-spl.bin 
-rw-r--r-- 1 bhu bhu 255476 81 16:05 rtos-with-spl.bin //生成文件

三 压缩rtos制作

3.1 软件配置

以ad100_nor_defconfig为例

1

勾选压缩rtos,使用lzma, 压缩的rtos固件加载可以使用到ddr所有大小

4

5

分包的目的是一边读取数据一边解码,加速启动

分包最大值是最多可以多少个包,需要和代码里面的值一致(一般不修改), 位于工程freertos/example/driver/load_rtos_split_example.c

9

包大小可以根据镜像大小调整

修改完成配置后保存, 编译rtos系统

bhu@bhu-PC:~/rtos/freertos$ source build/envsetup.sh
bhu@bhu-PC:~/rtos/freertos$ make ad100_nor_defconfig
bhu@bhu-PC:~/rtos/freertos$ make
bhu@bhu-PC:~/rtos/freertos$ ls -l zero_split.lzma 
-rw-r--r-- 1 bhu bhu 88841 81 17:32 zero_split.lzma //生成文件

四 烧录

6

分区划分:

boot : load rtos并解压,即二章节编译出来的镜像

rtos1 :选择压缩rtos镜像, 即三章节编译的镜像, 若不配置ota分区, 默认从rtos1启动, 若配置了ota分区, 可以选择rto1或rtos2启动

rtos2:选择压缩rtos镜像, 可通过写入ota分区信息, 切换分区启动, 不需要切换分区, 可以不配置

ota:通过ota分区内容判断从rtos1分区启动还是rtos2, 默认从rtos1分区启动, 烧录内容可为空, 不需要切换分区, 可以不配置

分区可修改, 代码位于工程freertos/example/driver/load_rtos_split_example.c

10

7

8

五 验证

U-Boot SPL 2013.07-00069-geb9101888 (Jul 01 2024 - 09:21:37)
V1.0.0 <2024/06/25>
ERROR EPC 83f9c84c
CPA_CPAPCR:0320490d
CPM_CPMPCR:0320490d
CPM_CPEPCR:0190510d
CPM_CPCCR:9a073310
DDR clk rate 600000000
DDR: M14F5121632A type is : DDR2
DDR_PAR of eFuse: 00000000 00000000
AD100 InnoPhy skew Settings...
GD25B512ME 00c8471a 00c8471a
[0.000085] gpio: VDDIO_SD(PD00~PD05) = 3.3V
[0.000493] sfc_nor: find chip:GD25B512ME id:0xc8471a
[0.000694] mount file system (rootfs) failed
[0.000898] vendor init... //load解压压缩的rtos
[0.022140] now use : rtos1 //进入默认rtos1分区
[0.000084] gpio: VDDIO_SD(PD00~PD05) = 3.3V
[0.000495] sfc_nor: find chip:GD25B512ME id:0xc8471a
[0.000695] mount file system (rootfs) failed
[0.000899] vendor init...

往ota分区写入信息ota:rtos2

$ nor_write 0x300000 0x6f 0x74 0x61 0x3a 0x72 0x74 0x6f 0x73 0x32
0x300000 #ota分区offset
6f 74 61 3a 72 74 6f 73 32 0a |ota:rtos2.|
U-Boot SPL 2013.07-00069-geb9101888 (Jul 01 2024 - 09:21:37)
V1.0.0 <2024/06/25>
ERROR EPC efffffff
CPA_CPAPCR:0320490d
CPM_CPMPCR:0320490d
CPM_CPEPCR:0190510d
CPM_CPCCR:9a073310
DDR clk rate 600000000
DDR: M14F5121632A type is : DDR2
DDR_PAR of eFuse: 00000000 00000000
AD100 InnoPhy skew Settings...
GD25B512ME 00c8471a 00c8471a
[0.000084] gpio: VDDIO_SD(PD00~PD05) = 3.3V
[0.000492] sfc_nor: find chip:GD25B512ME id:0xc8471a
[0.000694] mount file system (rootfs) failed
[0.000899] vendor init... //load解压压缩的rtos
[0.022143] now use : rtos2 //进入rtos2分区
[0.000083] gpio: VDDIO_SD(PD00~PD05) = 3.3V
[0.000492] sfc_nor: find chip:GD25B512ME id:0xc8471a
[0.000693] mount file system (rootfs) failed
[0.000898] vendor init...